package com.oasystem.service;

import java.util.List;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.oasystem.dao.jdbc.DepartmentDAO;
import com.oasystem.domain.Department;
import com.oasystem.domain.PagingBean;

@Transactional(readOnly = true)
public class DepartmentService {
	private DepartmentDAO departmentDAO;

	public void setDepartmentDAO(DepartmentDAO departmentDAO) {
		this.departmentDAO = departmentDAO;
	}

	@Transactional(readOnly = false, propagation = Propagation.SUPPORTS, rollbackFor = { Exception.class })
	public void insertDepartment(Department department) {
		departmentDAO.insertDepartment(department);
	}

	@Transactional(readOnly = false, propagation = Propagation.SUPPORTS, rollbackFor = { Exception.class })
	public void updateDepartment(Department department) {
		departmentDAO.updateDepartment(department);
	}

	public void getPagingDepartment(PagingBean<Department> pagingBean) {
		departmentDAO.getPagingDepartment(pagingBean);
	}
	
	public List<Department> getAllDepartment() {
		return departmentDAO.getAllDepartment();
	}

	public void loadDepartment(Department department) {
		departmentDAO.load(department);
	}

	@Transactional(readOnly = false, propagation = Propagation.SUPPORTS, rollbackFor = { Exception.class })
	public void deleteDepartment(Department department) {
		departmentDAO.deleteDepartment(department);
	}

	public boolean isDepartmentNameNotExist(String name) {
		return departmentDAO.isDepartmentNameNotExist(name);
	}
}
